summaryrefslogtreecommitdiff
path: root/src/pages/posts/[...slug].astro
blob: b68f153f269a34b7758f4c18098f35d1e455b7de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
import { getCollection, type CollectionEntry } from "astro:content";
import Layout from "@/layouts/main.astro";
import { buttonVariants } from "@/components/ui/button";
import PostHeader from "@/components/PostHeader.astro";

export async function getStaticPaths() {
  const posts = await getCollection("blog");

  return posts.map((post) => ({
    params: { slug: post.id },
    props: { post },
  }));
}

interface Props {
  post: CollectionEntry<"blog">;
}

const { post } = Astro.props as Props;
const { Content } = await post.render();
---

<Layout title={`${post.data.title} | Iwan Ingman's Blog`} description={post.data.description}>
  <main class="mx-auto flex w-full max-w-3xl flex-col gap-8 p-4 md:p-6">
    <PostHeader
      title={post.data.title}
      slug={post.id}
      description={post.data.description}
      author={post.data.author}
      publishDate={post.data.publishDate}
    />

    <article class="space-y-4 leading-relaxed">
      <Content />
    </article>

    <div>
      <a class={buttonVariants({ size: "xs", variant: "outline" })} href="/">Back to posts</a>
    </div>
  </main>
</Layout>